import { defineComponent, PropType, onMounted ,nextTick} from 'vue'
import TableContext from './table-context'

export default defineComponent({
  props: {
    p: {
      type: Object as PropType<TableContext>,
      required: true,
      default: () => null
    },
    addRequest:{
      type:Boolean,
      required: true,
      default:() => false
    }
  },
  setup(props) {
    const handleSelectionChange = (p, val) => {
      p.selected = val
    }

    const miniId = (id: string) => {
      if (!id) {
        return '-';
      }
      if (id.length == 36) {
        return id.substring(25).replaceAll('-', '');
      } else {
        return id;
      }
    }

    // onMounted
    onMounted(() => {
      nextTick(()=>{
        console.log('addRequest',props.addRequest)
      })
    });

    return {
      handleSelectionChange,
      miniId
    }
  }
})
